<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>日期</title>
    <style>
        h1{
        }
        .hide{
            display: none;
        }
        #date{
            text-align: center;
            font-size: 33px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <p id="date"></p>
    <hr>
    <h1 id="title" >标题！！！</h1>
    <button type="button" onclick="btnClick()">隐藏</button>
    <hr>
    <input type="text" id="username">
     <button type="button" onclick="getInputValue()">取值</button>
    <button type="button" onclick="setInputValue()">设置值</button>
    <hr>
    <button type="button" onclick="getRandom()">获取随机整数</button>

</body>
<!--引入jquery-->
    <script type="text/javascript" src="../lib/jquery.min.js"></script>
    <script type="text/javascript">

      var  timmeInteval;
        //页面加载完以后在加载出js
        $(function () {
            //alert("页面加载完成");
           // $("h1").dblclick(function () {//click单击h1消失   dblclick双击h1消失
             //   $(this).fadeOut();
          //  });

            setInterval(setDateTime,1000);//循环执行
            //setInterval(setDateTime(),1000); //延迟执行
        });
        function setDateTime() {
            let year = "";
            let month = "";
            let day = "";
            let hour = "";
            let minute = "";
            let seconds = "";

            let now = new Date();
            year = now.getFullYear();
            month = now.getMonth() + 1;
            if (month < 10)
                month = "0" + month;
            day = now.getDate();
            if (day < 10)
                day = "0" + day;
            hour = now.getHours();
            if (hour < 10)
                hour = "0" + hour;
            minute = now.getMinutes();
            if (minute < 10)
                minute = "0" + minute;
            seconds = now.getSeconds();
            if (seconds < 10)
                seconds = "0" + seconds;
            let str = year + "-" + month + "-" +day +" " + hour + ":" + minute + ":" + seconds;
            $("#date").html(str);
        }
       function btnClick() { //*动态修改内容
            //$("#title").fadeOut();//隐藏内容
          // $("#title").html("双体系");//改变内容
           // $("#title").css("color","red");//修改样式的颜色
           $("#title").toggleClass("hide");//切换效果
           //  $("#title").addClass("hide");//添加
           //  $("#title").removeClass("hide");//移除
        }
function getInputValue() {
   var a = $("#username").val();//取值
   alert(a);
}
function setInputValue() {
    $("#username").val("张三李四王五");//设置参数
}
function getRandom() {//获取随机数
    let num = Math.random() * 10000;
    num = Math.ceil(num);
    alert(num);
}
    </script>
</html>